
#ifndef __XB_CPU_ALU_H__
#define __XB_CPU_ALU_H__

/* ------------------------------------------------------------------------- */

#define alu_neg_byte(x)		alu_sub_byte(0, (x))
#define alu_neg_word(x)		alu_sub_word(0, (x))
#define alu_neg_dword(x)	alu_sub_dword(0, (x))

#define alu_not_byte(x)		(~(int8)(x))
#define alu_not_word(x)		(~(int16)(x))
#define alu_not_dword(x)	(~(int32)(x))

/* ------------------------------------------------------------------------- */

capi int8 fastcall alu_inc_byte(int8 x);
capi int16 fastcall alu_inc_word(int16 x);
capi int32 fastcall alu_inc_dword(int32 x);

capi int8 fastcall alu_dec_byte(int8 x);
capi int16 fastcall alu_dec_word(int16 x);
capi int32 fastcall alu_dec_dword(int32 x);

capi int8 fastcall alu_add_byte(int8 x, int8 y);
capi int16 fastcall alu_add_word(int16 x, int16 y);
capi int32 fastcall alu_add_dword(int32 x, int32 y);

capi int8 fastcall alu_sub_byte(int8 x, int8 y);
capi int16 fastcall alu_sub_word(int16 x, int16 y);
capi int32 fastcall alu_sub_dword(int32 x, int32 y);

capi int8 fastcall alu_adc_byte(int8 x, int8 y);
capi int16 fastcall alu_adc_word(int16 x, int16 y);
capi int32 fastcall alu_adc_dword(int32 x, int32 y);

capi int8 fastcall alu_sbb_byte(int8 x, int8 y);
capi int16 fastcall alu_sbb_word(int16 x, int16 y);
capi int32 fastcall alu_sbb_dword(int32 x, int32 y);

capi int8 fastcall alu_and_byte(int8 x, int8 y);
capi int16 fastcall alu_and_word(int16 x, int16 y);
capi int32 fastcall alu_and_dword(int32 x, int32 y);

capi int8 fastcall alu_or_byte(int8 x, int8 y);
capi int16 fastcall alu_or_word(int16 x, int16 y);
capi int32 fastcall alu_or_dword(int32 x, int32 y);

capi int8 fastcall alu_xor_byte(int8 x, int8 y);
capi int16 fastcall alu_xor_word(int16 x, int16 y);
capi int32 fastcall alu_xor_dword(int32 x, int32 y);

capi int8 fastcall alu_rol_byte(int8 x, uint8 y);
capi int16 fastcall alu_rol_word(int16 x, uint8 y);
capi int32 fastcall alu_rol_dword(int32 x, uint8 y);

capi int8 fastcall alu_ror_byte(int8 x, uint8 y);
capi int16 fastcall alu_ror_word(int16 x, uint8 y);
capi int32 fastcall alu_ror_dword(int32 x, uint8 y);

capi int8 fastcall alu_rcl_byte(int8 x, uint8 y);
capi int16 fastcall alu_rcl_word(int16 x, uint8 y);
capi int32 fastcall alu_rcl_dword(int32 x, uint8 y);

capi int8 fastcall alu_rcr_byte(int8 x, uint8 y);
capi int16 fastcall alu_rcr_word(int16 x, uint8 y);
capi int32 fastcall alu_rcr_dword(int32 x, uint8 y);

capi int8 fastcall alu_shl_byte(int8 x, uint8 y);
capi int16 fastcall alu_shl_word(int16 x, uint8 y);
capi int32 fastcall alu_shl_dword(int32 x, uint8 y);

capi int8 fastcall alu_shr_byte(int8 x, uint8 y);
capi int16 fastcall alu_shr_word(int16 x, uint8 y);
capi int32 fastcall alu_shr_dword(int32 x, uint8 y);

capi int8 fastcall alu_sar_byte(int8 x, uint8 y);
capi int16 fastcall alu_sar_word(int16 x, uint8 y);
capi int32 fastcall alu_sar_dword(int32 x, uint8 y);

capi uint8 fastcall alu_mul_byte(uint8 x, uint8 y, uint8 *h);
capi uint16 fastcall alu_mul_word(uint16 x, uint16 y, uint16 *h);
capi uint32 fastcall alu_mul_dword(uint32 x, uint32 y, uint32 *h);

capi int8 fastcall alu_imul_byte(int8 x, int8 y, int8 *h);
capi int16 fastcall alu_imul_word(int16 x, int16 y, int16 *h);
capi int32 fastcall alu_imul_dword(int32 x, int32 y, int32 *h);

capi uint8 fastcall alu_div_byte(uint16 x, uint8 y, uint8 *w);
capi uint16 fastcall alu_div_word(uint32 x, uint16 y, uint16 *w);
capi uint32 fastcall alu_div_dword(uint64 x, uint32 y, uint32 *w);

capi int8 fastcall alu_idiv_byte(int16 x, int8 y, int8 *w);
capi int16 fastcall alu_idiv_word(int32 x, int16 y, int16 *w);
capi int32 fastcall alu_idiv_dword(int64 x, int32 y, int32 *w);

capi uint16 fastcall alu_bt_word(uint16 x, uint8 y);
capi uint32 fastcall alu_bt_dword(uint32 x, uint8 y);

capi uint16 fastcall alu_bts_word(uint16 x, uint8 y);
capi uint32 fastcall alu_bts_dword(uint32 x, uint8 y);

capi uint16 fastcall alu_btr_word(uint16 x, uint8 y);
capi uint32 fastcall alu_btr_dword(uint32 x, uint8 y);

capi uint16 fastcall alu_btc_word(uint16 x, uint8 y);
capi uint32 fastcall alu_btc_dword(uint32 x, uint8 y);

/* ------------------------------------------------------------------------- */

#endif
